<template>
  <search-table
    :data="potentialVulnerabilityData"
    :columns="columns"
    :page.sync="queryParams.pageIndex"
    :size.sync="queryParams.pageSize"
    :total="potentialVulnerabilityTotal"
    :loading="potentialVulnerabilityLoading"
    @queryFun="getNewData">
        <Modal
          v-model="modalDeatilData.show"
          title="潜在漏洞详情"
          footer-hide
          class="my-modal">
          <div class="item-table">
            <p>
              <span class='label'>组件名称</span>
              <span>{{ detailInfo.name }}</span>
            </p>
            <p>
              <span class='label'>组件类型</span>
              <span>{{ productPartTypeEscape(detailInfo.type).text }}</span>
            </p>
            <p>
              <span class='label'>漏洞评级</span>
              <span>{{ vulnerabilityLevelEscape(detailInfo.level).text }}</span>
            </p>
            <p>
              <span class='label'>版本号</span>
              <span>{{ detailInfo.version }}</span>
            </p>
            <p>
              <span class='label'>分组</span>
              <span>{{ detailInfo.groupId }}</span>
            </p>
            <p>
              <span class='label'>漏洞名称</span>
              <span>{{ detailInfo.vulnerabilityName }}</span>
            </p>
            <p>
              <span class='label'>CVE</span>
              <span>{{ detailInfo.cve }}</span>
            </p>
            <p>
              <span class='label'>风险评分</span>
              <span>{{ detailInfo.lastInheritedRiskScore }}</span>
            </p>
            <p>
              <span class='label'>关联部件数</span>
<!--               @click="showPartModal(detailInfo)"-->
              <span><Button size="small" type="info">{{ detailInfo.partNum }}</Button></span>
            </p>
            <p>
              <span class='label'>关联组件数</span>
<!--               @click="showComponentModal(detailInfo)"-->
              <span><Button size="small" type="info">{{ detailInfo.componentNum }}</Button></span>
            </p>
            <p>
              <span class='label'>发现时间</span>
              <span>{{ detailInfo.discoverTime }}</span>
            </p>
          </div>
        </Modal>
        <Modal
          v-model="availabilityModal.show"
          title="潜在漏洞可用性"
          @on-visible-change="changeAvailabilityVisible"
          class="my-modal">
          <Form
            ref="availabilityFormInline"
            :label-width="110"
            :model="availabilityModal.formInline"
            :rules="availabilityModal.ruleInline">
            <FormItem prop="productName" label="产品名称">
                <Input v-model="availabilityModal.formInline.productName" disabled></Input>
            </FormItem>
            <FormItem prop="vulnerabilityName" label="漏洞名称">
                <Input v-model="availabilityModal.formInline.vulnerabilityName" disabled></Input>
            </FormItem>
            <FormItem prop="status" label="影响产品状态">
                <Select filterable transfer filterable clearable v-model="availabilityModal.formInline.status" placeholder=""
                  @on-change="changeStatus">
                  <Option v-for="(item, index) in statusOptions" :value="index" :key="index">{{ item }}</Option>
                </Select>
            </FormItem>
            <FormItem prop="type"  label="影响类型">
                <Select filterable transfer filterable clearable v-model="availabilityModal.formInline.type" placeholder="">
                  <Option v-for="(item, index) in typeOptions" :value="index" :key="index">{{ item }}</Option>
                </Select>
            </FormItem>
            <!-- 确定不影响时，威胁说明不能为空，其他类型不做校验 -->
            <FormItem prop="description"  label="威胁说明"
              :rules="availabilityModal.formInline.status === 3
                ? {required: true, message: '威胁说明不能为空', trigger: 'blur,change'}
                : {}"
              >
                <Input v-model="availabilityModal.formInline.description" type="textarea" :rows="3"></Input>
            </FormItem>
            <FormItem prop="fixType"  label="补救方式">
                <Select filterable transfer filterable clearable v-model="availabilityModal.formInline.fixType" placeholder="">
                  <Option v-for="(item, index) in fixTypeOptions" :value="index" :key="index">{{ item }}</Option>
                </Select>
            </FormItem>
            <!-- 确定影响时，补救措施不能为空，其他类型不做校验 -->
            <FormItem prop="solution"  label="补救措施"
              :rules="availabilityModal.formInline.status === 2
                ? {required: true, message: '补救措施不能为空', trigger: 'blur,change'}
                : {}"
              >
              <Input v-model="availabilityModal.formInline.solution" type="textarea" :rows="3"></Input>
            </FormItem>
          </Form>
          <div slot="footer" class="footer">
            <Button @click="availabilityModal.show = false">取消</Button>
            <Button @click="saveAvailability" :loading="availabilityModal.loading" type="primary">确定</Button>
          </div>
        </Modal>
  </search-table>
</template>
<script>
import {
  queryComponentVulnerabilityList,
  addComponentVulnerability,
  deleteComponentVulnerability
} from '../api/productComponentVulnerability'
import {
  getRelationModule
} from '../api/productComponent'
import {
  addProductComponentVulnerabilityImpact,
  updateProductComponentVulnerabilityImpact,
  getProductComponentVulnerabilityImpactDetail
} from '../api/productComponentVulnerabilityImpact'
import {
  addProductComponentVulnerabilityRecurrence,
  updateProductComponentVulnerabilityRecurrence,
  getProductComponentVulnerabilityRecurrenceDetail
} from '../api/productComponentVulnerabilityRecurrence'
import {
  getRelevancePartList
} from '../api/productPart'

import {productPartTypeEscape} from "../logic/assetLogic";
import {vulnerabilityLevelEscape} from "../../vulnerability/logic/vulnerabilityLogic";


export default {
  name: 'ProductGroup',
  props: {
    partId: { // 部件ID
      type: String,
      default: ''
    },
    productId: { // 产品ID
      type: String,
      default: ''
    },
    moduleId: { // 组件ID
      type: String,
      default: ''
    },
    allowAdd: {
      type: Boolean,
      default: false
    },
    disabledOperation: {
      type: Boolean,
      default: false
    },
  },
  computed: {
    productName() {
      return this.$route.query.assetName
    },
  },
  data() {
    return {
      potentialVulnerabilityLoading:false,
      potentialVulnerabilityData:[],
      potentialVulnerabilityTotal:0,
      vulnerabilityLevelEscape,
      productPartTypeEscape,
      queryParams: {
        pageIndex:1,
        pageSize:10
      },
      modalData: {
        show: false,
        loading: false
      },
      formInline: {
        ids: '',
      },
      ruleInline: {
        ids: [
          { required: true, type: 'array', message: '关联漏洞不能为空', trigger: 'blur,change' }
        ],
      },
      testItemList: [],
      testCaseList: [],
      testProjectList: [],
      statusOptions: ['新建', '测试中', '确定影响', '确定不影响', '已修复', '误报'],
      typeOptions: ['威胁', '漏洞标签'],
      fixTypeOptions: ['无补救措施', '打补丁', '升级', '修改应用程序', '无需补救'],
      availabilityModal: {
        show: false,
        isAdd: false,
        loading: false,
        formInline: {
          description: '',
          fixType: '',
          productId: '',
          productName: '',
          vulnerabilityId: '',
          vulnerabilityName: '',
          type: '',
          solution: ''
        },
        ruleInline: {
          productName: [
            { required: true, message: '产品名称不能为空', trigger: 'blur,change' }
          ],
          vulnerabilityName: [
            { required: true, message: '漏洞名称不能为空', trigger: 'blur,change' }
          ],
          fixType: [
            { required: true, type: 'number', message: '补救方式不能为空', trigger: 'blur,change' }
          ],
          type: [
            { required: true, type: 'number', message: '影响类型不能为空', trigger: 'blur,change' }
          ],
          status: [
            { required: true, type: 'number', message: '影响产品状态不能为空', trigger: 'blur,change' }
          ],
        }
      },
      recurrenceModal: {
        show: false,
        isAdd: false,
        loading: false,
        formInline: {
          description: '',
          productId: '',
          productName: '',
          vulnerabilityId: '',
          vulnerabilityName: '',
          testProjectId: '',
          testItemId: '',
          testItemCaseIds: [],
          type: 0
        },
        ruleInline: {
          productName: [
            { required: true, message: '产品名称不能为空', trigger: 'blur,change' }
          ],
          vulnerabilityName: [
            { required: true, message: '漏洞名称不能为空', trigger: 'blur,change' }
          ],
          testProjectId: [
            { required: true, message: '测试项目不能为空', trigger: 'blur,change' }
          ],
          testItemId: [
            { required: true, message: '测试项不能为空', trigger: 'blur,change' }
          ],
          testItemCaseIds: [
            { required: true, type: 'array', message: '测试用例不能为空', trigger: 'blur,change' }
          ],
        }
      },
      modalDeatilData: {
        show: false,
      },
      detailInfo: {},
      // columns: [
      //     {
      //         title:'组件名称',
      //         key:'name',
      //     },
      //     {
      //         title:'版本',
      //         key:'version'
      //     },
      //     {
      //         title:'组件类型',
      //         key:'type',
      //     },
      //     {
      //         title:'分组',
      //         key:'groupId'
      //     },
      //     {
      //         title:'许可类型',
      //         key:'licenseType',
      //     },
      //     {
      //         title:'最大威胁',
      //         key:'maxThreatValue'
      //     },
      //     {
      //         title:'风险评分',
      //         key:'lastInheritedRiskScore'
      //     },
      //     {
      //         title: '操作',
      //         slot: 'action',
      //         width: 320,
      //         actions: [
      //             {
      //                 label: '详情',
      //                 fn: (obj) => {
      //                     this.detailModalData.show = true
      //                     this.detailInfo = obj
      //                 }
      //             },
      //             {
      //                 label: '修改',
      //                 fn:(obj)=>{
      //                     this.showModal(obj)
      //                 },
      //             },
      //             {
      //                 label: '外部参考链接',
      //                 fn: (obj) => {
      //                     this.drawerData.externalLinks = true
      //                     this.$nextTick(() => {
      //                         this.$refs.externalLinks.init(obj)
      //                     })
      //                 },
      //             },
      //             {
      //                 label: '关联威胁',
      //                 fn:(obj)=>{
      //                     this.downloadFile(obj.resSoftware)
      //                 },
      //                 disabledFn: obj => {
      //                     return !(obj.resSoftware && obj.resSoftware.fileId) || false
      //                 }
      //             },
      //             {
      //                 label: '删除',
      //                 isDelete:true,
      //                 confirm: true,
      //                 confirmText: '确定要删除组件与资产的关联关系吗',
      //                 fn: obj => this.deleteItem([obj.id])
      //             },
      //         ]
      //     }
      // ],
      searchFn: queryComponentVulnerabilityList,
      //搜索模块
      textFields: [
      ],
      formData:{
          productId: this.productId,
          partId: this.partId,
          componentId: this.moduleId
      },
      fieldChangeCallbacks:{
      },
      formStyle:{
          direction:'horizon',
          left:true
      },
      textFields1: [
      ],
      formData1:{
      },
      fieldChangeCallbacks1:{
      },
      formStyle1:{
          direction:'horizon',
          right:true
      },
      partModal: {
        show: false,
        title: '关联部件',
        resData: {
          total: 0,
          list: [],
          loading: true
        },
        queryParams: {
          pageIndex: 1,
          pageSize: 10,
        },
        // columns: [
        //   {
        //     title: '部件名称',
        //     key: 'name',
        //   },
        //   {
        //       title: '软硬件',
        //       placement: 'top-right',
        //       key: 'type',
        //       render: (h, params) => {
        //           let ret = params.row.type === 0 ? {
        //             color: 'cyan',
        //             text: '软件'
        //           } : {
        //             color: 'purple',
        //             text: '硬件'
        //           }
        //           return h('Tag', {
        //               props: {
        //                   color: ret.color
        //               },
        //               style: {
        //                   width: '60px',
        //                   'text-align': 'center'
        //               }
        //           }, ret.text)
        //       }
        //   },
        //   {
        //     placement: 'top-right',
        //     title: '部件类型',
        //     key: 'partType',
        //     render: (h, params) => {
        //         let ret = this.$CodeEscape.productPartTypeEscape(params.row.partType)
        //         return h('Tag', {
        //             props: {
        //                 color: ret.color
        //             },
        //             style: {
        //                 width: '70px',
        //                 'text-align': 'center'
        //             }
        //         }, ret.text)
        //     }
        //   },
        //   {
        //     title: '供应商',
        //     key: 'supplier',
        //   },
        //   {
        //     title: '型号',
        //     key: 'model',
        //   },
        //   {
        //     title: '版本',
        //     key: 'version',
        //   },
        //   {
        //     title: '风险评分',
        //     key: 'lastInheritedRiskScore',
        //   }
        // ],
        columns1: [
          {
            title: '组件名称',
            key: 'name',
          },
          {
              placement: 'top-right',
              title: '组件类型',
              key: 'type',
              render: (h, params) => {
                  let ret = productPartTypeEscape(params.row.type)
                  return h('Tag', {
                      props: {
                          color: ret.color
                      },
                      style: {
                          width: '70px',
                          'text-align': 'center'
                      }
                  }, ret.text)
              }
          },
          {
              title: '许可类型',
              key: 'licenseType',
          },
          {
              title: '版本号',
              key: 'version',
          },
          {
              title: '分组',
              key: 'groupId',
          },
          {
              title: '内部标识',
              key: 'swid',
          }
        ]
      },
      vulnerabilityName: '',
      columns: [
        {
          title: '漏洞名称',
          key: 'vulnerabilityName',
        },
        {
          title: '版本号',
          key: 'version',
        },
        {
          title: '分组',
          key: 'groupId',
        },
        {
          title: '组件名称',
          key: 'name',
        },
        {
          title: 'CVE',
          key: 'cve',
        },
        {
          title: '关联部件数',
          key: 'partNum',
          tooltip: true,
          width: 120,
          render:(h,params)=>{
            return h('Button',{
              props: {
                size: 'small',
                type: 'info'
              },
              on: {
                click: () => {
                  this.showPartModal(params.row)
                }
              }
            }, params.row.partNum)
          }
        },
        {
          title: '关联组件数',
          key: 'componentNum',
          tooltip: true,
          width: 120,
          render:(h,params)=>{
            return h('Button',{
              props: {
                size: 'small',
                type: 'info'
              },
              on: {
                click: () => {
                  this.showComponentModal(params.row)
                }
              }
            }, params.row.componentNum)
          }
        },
        {
          placement: 'top-right',
          title: '漏洞评级',
          key: 'level',
          render: (h, params) => {
              let ret = this.$CodeEscape.vulnerabilityLevelEscape(params.row.level)
              return h('Tag', {
                  props: {
                      color: ret.color
                  },
                  style: {
                      width: '70px',
                      'text-align': 'center'
                  }
              }, ret.text)
          }
        },
        {
          title: '风险评分',
          key: 'lastInheritedRiskScore',
          tooltip: true,
          width: 120,
        },
        {
          title: '操作',
          slot: 'action',
          width: 170,
          opList: [
              {
                  txt: '详情',
                  fun: (obj) => {
                    this.detailInfo = obj
                    this.modalDeatilData.show = true
                  }
              },
              {
                  txt: '可用性',
                  fun:(obj)=>{
                      this.showAvailabilityModal(obj)
                  },
              }
          ]
        },
      ],
      allComponentVulnerabilityList: [],
      isPart: true
    }
  },
  mounted(){
    //this.getAllComponentVulnerabilityList()
  },
  methods:{
    // 重新或许可选项，并自动选中刚刚创建的数据
    freshData(id) {
      this.getTestProjectList()
      this.recurrenceModal.formInline.testProjectId = id
    },
    init(obj){
      this.currentItem = obj;
      this.getNewData();
    },
    getNewData(){
      this.potentialVulnerabilityLoading = true;
      let params = {
        ...this.queryParams
      }
      params.productId = this.$route.query.productId;
      params.partId = this.$route.query.id;
      params.componentId = this.currentItem.id;
      queryComponentVulnerabilityList(params).then(res=>{
        if(res.code===1){
          this.potentialVulnerabilityData = res.data.items;
          this.potentialVulnerabilityTotal = res.data.total;
        }else{
          this.$Message.error(res.message);
        }
      }).finally(()=>{
        this.potentialVulnerabilityLoading = false;
      })
    },
    // 获取所有的潜在漏洞，用于控制子组件哪些数据不可选
    getAllComponentVulnerabilityList(){
      queryComponentVulnerabilityList({
        pageIndex: 1,
        pageSize: 2147483646,
        productId: this.productId,
        partId: this.partId,
        componentId: this.moduleId
      }).then(({ code, data }) => {
        if (code !== 1) {
          this.allComponentVulnerabilityList = []
          return
        }
        this.allComponentVulnerabilityList = (data.items || []).map(item => item.vulnerabilityId)
      }).catch(() => {
        this.allComponentVulnerabilityList = []
      })
    },
    // 将公共漏洞关联为潜在漏洞
    addComponentVulnerability() {
      let list = this.formInline.ids.map(vulnerabilityId => {
        return {
          componentId: this.moduleId,
          vulnerabilityId: vulnerabilityId
        }
      })
      // 目前接口只支持单数据添加，从数组中取一个值去添加，后期有变动也方便实现
      addComponentVulnerability(list[0]).then(({ code, message }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.$Message.success('关联公共漏洞成功')
        this.getNewData()
        this.getAllComponentVulnerabilityList()
        this.modalData.show = false
      }).catch(() => {
        this.$Message.error('关联公共漏洞异常')
      })
    },
    // 删除公共漏洞的关联关系
    deleteComponentVulnerability(componentId, vulnerabilityId) {
      deleteComponentVulnerability(componentId, vulnerabilityId).then(({ code, message }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.$Message.success('删除公共漏洞的关联关系成功')
        // 删除后展示当前页，当前页没有数据展示前一页
        this.$refs.tableContent.queryParams.pageIndex = (this.$refs.tableContent.resData.list.length == 1 && this.$refs.tableContent.queryParams.pageIndex > 1) ?
                        this.$refs.tableContent.queryParams.pageIndex - 1 : this.$refs.tableContent.queryParams.pageIndex;
        this.$refs.tableContent.getDataList()
        this.getAllComponentVulnerabilityList()
      }).catch(() => {
        this.$Message.error('删除公共漏洞的关联关系异常')
      })
    },
    // 打开模态框，视接口返回的数据结构进行后续处理，暂时未完成功能
    showModal() {
        this.modalData.show = true
    },
    // 漏洞修改后，需要验证
    validateVulnerabilityIds() {
        this.$nextTick(() => {
            this.$refs.formInline.validateField('ids')
        })
    },
    // 隐藏模态框时，重置表单数据
    changeVisible(type) {
      if (!type) {
        this.$refs.formInline.resetFields()
        this.modalData.loading = false
        this.$refs.publicVulnerabilitySelectDrawer.clear()
      }
    },
    // 影响产品状态改变时，重新交验威胁说明与补救措施
    changeStatus() {
      this.$nextTick(() => {
        this.$refs.availabilityFormInline.validateField('solution')
        this.$refs.availabilityFormInline.validateField('description')
      })
    },
    // 隐藏模态框时，重置表单数据
    changeAvailabilityVisible(type) {
      if (!type) {
        this.$refs.availabilityFormInline.resetFields()
        this.availabilityModal.loading = false
      }
    },
    // 漏洞复现模态框隐藏时触发
    changeRecurrenceVisible(type) {
      if (!type) {
        this.$refs.recurrenceFormInline.resetFields()
        this.recurrenceModal.loading = false
      }
    },
    // 测试项目改变时，重新获取对用的测试项与测试用例
    changeTestProject() {
      this.$set(this.recurrenceModal.formInline, 'testItemId', '')
      this.$set(this.recurrenceModal.formInline, 'testItemCaseIds', [])
      this.getTestItemList()
    },
    // 测试项改变时，重新获取对应的测试用例
    changeTestItem() {
      this.$set(this.recurrenceModal.formInline, 'testItemCaseIds', [])
      this.getTestCaseList()
    },
    // 保存或者修改漏洞复现
    saveRecurrence() {
      this.$refs.recurrenceFormInline.validate(valid => {
        if (valid) {
          this.recurrenceModal.loading = true
          let apiName = this.recurrenceModal.isAdd ? addProductComponentVulnerabilityRecurrence : updateProductComponentVulnerabilityRecurrence
          let data = Object.assign({}, this.recurrenceModal.formInline)
          apiName(data).then(({ code, message }) => {
            if (code !== 1) {
              this.$Message.warning(message)
              return
            }
            // 创建成功
            this.$Message.success(`${this.recurrenceModal.isAdd ? '创建' : '修改'}漏洞复现成功`)
            this.getNewData()
            this.recurrenceModal.show = false
          }).catch(() => {
            this.$Message.error(`${this.recurrenceModal.isAdd ? '创建' : '修改'}漏洞复现异常`)
          }).finally(() => {
            this.recurrenceModal.loading = false
          })
        }
      })
    },
    // 查询潜在漏洞关联的可用性，存在数据则修复，没有数据则创建
    showAvailabilityModal(obj) {
      this.availabilityModal.show = true
      getProductComponentVulnerabilityImpactDetail(this.productId, obj.vulnerabilityId).then(({ code, message, data = {} }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.availabilityModal.isAdd = !data
        this.availabilityModal.formInline = Object.assign({
          productId: this.productId,
          productName: this.productName,
          vulnerabilityId: obj.vulnerabilityId,
          vulnerabilityName: obj.vulnerabilityName
        }, data || {})
      })
    },
    // 保存或者修改漏洞可用性
    saveAvailability() {
      this.$refs.availabilityFormInline.validate(valid => {
        if (valid) {
          this.availabilityModal.loading = true
          let apiName = this.availabilityModal.isAdd ? addProductComponentVulnerabilityImpact : updateProductComponentVulnerabilityImpact
          let data = Object.assign({}, this.availabilityModal.formInline)
          apiName(data).then(({ code, message }) => {
            if (code !== 1) {
              this.$Message.warning(message)
              return
            }
            // 创建成功
            this.$Message.success(`${this.availabilityModal.isAdd ? '创建' : '修改'}漏洞可用性成功`)
            this.getNewData()
            this.availabilityModal.show = false
          }).catch(() => {
            this.$Message.error(`${this.availabilityModal.isAdd ? '创建' : '修改'}漏洞可用性异常`)
          }).finally(() => {
            this.availabilityModal.loading = false
          })
        }
      })
    },
    changePartPageNow(val) {
      this.partModal.queryParams.pageIndex = val || this.partModal.queryParams.pageIndex;
      this.isPart ? this.getRelevancePartList() : this.getRelationModuleList()
    },
    // 打开模态框展示关联部件列表
    showPartModal(obj) {
      this.isPart = true
      this.partModal.show = true
      this.partModal.title = '关联部件'
      this.partModal.queryParams.pageIndex = 1
      this.vulnerabilityName = obj.vulnerabilityName
      this.detailModuleId = obj.id
      this.getRelevancePartList(obj.id)
    },
    // 打开模态框展示关联组件列表
    showComponentModal(obj) {
      this.isPart = false
      this.partModal.show = true
      this.partModal.title = '关联组件'
      this.partModal.queryParams.pageIndex = 1
      this.vulnerabilityName = obj.vulnerabilityName
      this.detailModuleId = obj.id
      this.getRelationModuleList(obj.id)
    },
    // 查询关联的组件列表
    getRelationModuleList(id) {
      this.$set(this.partModal.resData, 'loading', true)
      getRelationModule(id || this.detailModuleId).then(({ code, message, data = {} }) => {
          if (code !== 1) {
              this.$Message.warning(message)
              return
          }
          let list = data || []
          this.partModal.resData.total = list.length
          this.partModal.resData.list = list.slice((this.partModal.queryParams.pageIndex - 1) * this.partModal.queryParams.pageSize, this.partModal.queryParams.pageIndex * this.partModal.queryParams.pageSize)
      }).catch(() => {
          this.$Message.error(`获取关联组件列表异常`)
      }).finally(() => {
        this.$set(this.partModal.resData, 'loading', false)
      })
    },
    // 获取关联部件列表
    getRelevancePartList(id) {
      this.$set(this.partModal.resData, 'loading', true)
      getRelevancePartList(id || this.detailModuleId, this.partModal.queryParams).then(({ code, message, data = {} }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.partModal.resData = {
          total: data.total || 0,
          list: data.items || []
        }
      }).catch(() => {
        this.$Message.error('获取关联部件列表异常')
      }).finally(() => {
        this.$set(this.partModal.resData, 'loading', false)
      })
    },
    // 查询所有测试项
    getTestItemList() {
      if (!this.recurrenceModal.formInline.testProjectId) {
        return
      }
      queryTestItemList({
        pageIndex: 1,
        pageSize: 2147483646,
        testProjectId: this.recurrenceModal.formInline.testProjectId
      }).then(({ code, message, data = {} }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.testItemList = data.items || []
      }).catch(() => {
        this.$Message.error('获取测试项目下的测试项异常')
      })
    },
    // 查询所有测试用例
    getTestCaseList() {
      if (!this.recurrenceModal.formInline.testItemId) {
        return
      }
      queryTestCaseList({
        pageIndex: 1,
        pageSize: 2147483646,
        testProjectId: this.recurrenceModal.formInline.testProjectId,
        testItemId: this.recurrenceModal.formInline.testItemId
      }).then(({ code, message, data = {} }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.testCaseList = data.items || []
      }).catch(() => {
        this.$Message.error('获取测试项目下的测试用例异常')
      })
    },
    // 获取所有测试项目
    getTestProjectList() {
      queryTestProjectList({
        pageIndex: 1,
        pageSize: 2147483646,
      }).then(({ code, message, data = {} }) => {
        if (code !== 1) {
          this.$Message.warning(message)
          return
        }
        this.testProjectList = data.items || []
      }).catch(() => {
        this.$Message.error('获取测试项目详情异常')
      })
    },
  }
}
</script>

<style scoped>
.product-group {
  width: 100%;
  height: calc(100% - 30px);
  overflow: hidden;
}

.product-group .table-body{
    height: 100%;
}

.item-table {
    display: table;
    width: 100%;
    border: 1px solid #eee;
    table-layout: fixed;
    word-break: break-all;
}

.item-table p {
    display: table-row;
    line-height: 36px;
    text-align: center;
}

.item-table p span {
    display: table-cell;
    border-bottom: 1px solid #eee;
}

.my-form-item {
    position: relative;
}
.my-form-item /deep/ .ivu-form-item-content {
    display: flex;
}
.my-form-item /deep/ .ios-alert {
    color: orange;
    font-size: 16px;
    cursor: pointer;
}
.my-modal /deep/ .list-page {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
}
.space-flex{
  display: flex;
  align-items: center;
}
</style>
